using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace CustomerMgr.Data.Models.Mapping
{
    public class DebitMap : EntityTypeConfiguration<Debit>
    {
        public DebitMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Name)
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("Debit");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.CustomerId).HasColumnName("CustomerId");
            this.Property(t => t.CreateDate).HasColumnName("CreateDate");
            this.Property(t => t.Repayment).HasColumnName("Repayment");

            // Relationships
            this.HasRequired(t => t.Customer)
                .WithMany(t => t.Debits)
                .HasForeignKey(d => d.CustomerId);

        }
    }
}
